// 1. byteSize：返回字符串的字节长度
// const byteSize = (str) => new Blob([ str ]).size;

// console.log(byteSize('😀')); // 4
// console.log(byteSize('Hello World')); // 11

// 2. capitalize：首字母大写
const capitalize = ([ first, ...rest ]) => first.toUpperCase() + rest.join('');

capitalize('fooBar'); // 'FooBar'
capitalize('fooBar', true); // 'Foobar'

// 3. capitalizeEveryWord：每个单词首字母大写
const capitalizeEveryWord = (str) => str.replace(/\b[a-z]/g, (char) => char.toUpperCase());

console.log(capitalizeEveryWord('hello world!')); // 'Hello World!'

// 3. decapitalize：首字母小写
const decapitalize = ([ first, ...rest ]) => first.toLowerCase() + rest.join('');

decapitalize('FooBar'); // 'fooBar'
decapitalize('FooBar'); // 'fooBar'

// 4. splitLines：将多行字符串拆分为行数组。
const splitLines = (str) => str.split(/\r?\n/);

splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , '']

// 5. stripHTMLTags：删除字符串中的HTMl标签
const stripHTMLTags = (str) => str.replace(/<[^>]*>/g, '');

stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'
